<?php
//控制器

class insert extends mysql
{
    function dateinsert()
    {
        //提交新留言
        if (isset($_REQUEST['insert'])) {
            if (!empty($_POST)) {
                $text = $_POST['text'];
                $p_id = $_SESSION['id'];
                $g_id = $_POST['g_id'];
                $time = date('Y-m-d H:i:s');
                $table = 'message';
                $data = array(
                    'p_id' => $p_id,
                    'g_id' => $g_id,
                    'text' => $text,
                    'time' => $time
                );
                $ints = $this->insert($data, $table);
                if ($ints == true) {
                    $this->success(0,'index','home','userhome',"发送成功。");
                } else {
                    $this->alert_str("发送失败！");
                }
            }
        }

        $id = $_SESSION["id"];
        $name = $_SESSION["username"];

        //查询全部用户
        $sql2 = "select * from user_table where dd = 0";
        $user =  $this->select_all($sql2);
        $this->display('index', 'index', 'insert', ['url' => $this->config, 'ueditor' => $this->ueditor,'js' => $this->js ,'user' => $user,'_SESSION' => $_SESSION]);
    }
}